// index.js
const {
  get
} = require('../../utils/request')
const {
  baseUrl
} = require('../../utils/config')
Page({
  data: {
    // 文章列表数据
    articleListData: [],
    baseUrl: baseUrl,
    searchImg: '../../static/images/search.png'
  },
  onLoad(options) {
    this.getArticleListData()
  },
  // 获取文章列表的数据
  async getArticleListData() {
   let result = await get(`${baseUrl}articleList`)
   this.setData({
    articleListData: result
   })
  },
  // 跳转详情页
  goDetail(e) {
    const article_id = e.currentTarget.dataset.articleId;
    wx.navigateTo({
      url: `/pages/detail/detail?article_id=${article_id}`,
    })
  }
})